package tools

import (
	. "go-caipu/pkg/services/sqlstore/migrator"
)

func AddSysToolsTableMigrations(mg *Migrator) {
	userV1 := Table{
		Name: "sys_tools_table",
		Columns: []*Column{
			{Name: "table_id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
			{Name: "table_name", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "table_comment", Type: DB_NVarchar, Length: 255, Nullable: false},
			{Name: "class_name", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "tpl_category", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "package_name", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "module_name", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "module_front_name", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "business_name", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "function_name", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "function_author", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "pk_column", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "pk_go_field", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "pk_json_field", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "options", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "tree_code", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "tree_parent_code", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "tree_name", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "tree", Type: DB_TinyInt, Length: 1, Nullable: true},
			{Name: "crud", Type: DB_TinyInt, Length: 1, Nullable: true},
			{Name: "remark", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "is_data_scope", Type: DB_TinyInt, Length: 1, Nullable: true},
			{Name: "is_actions", Type: DB_TinyInt, Length: 1, Nullable: true},
			{Name: "is_auth", Type: DB_TinyInt, Length: 1, Nullable: true},
			{Name: "is_logical_delete", Type: DB_TinyInt, Length: 1, Nullable: true},
			{Name: "logical_delete", Type: DB_TinyInt, Length: 1, Nullable: true},
			{Name: "logical_delete_column", Type: DB_NVarchar, Length: 128, Nullable: true},
			{Name: "is_configed", Type: DB_Bool, Nullable: true},
			{Name: "created_at", Type: DB_DateTime, Nullable: false},
			{Name: "updated_at", Type: DB_DateTime, Nullable: true},
			{Name: "deleted_at", Type: DB_DateTime, Nullable: true},
			{Name: "create_by", Type: DB_BigInt, Nullable: false},
			{Name: "update_by", Type: DB_BigInt, Nullable: true},
		},
		Indices: []*Index{
			{Cols: []string{"deleted_at", "table_id"}, Type: UniqueIndex},
		},
	}
	//create table
	mg.AddMigration("create table sys_tools_table", NewAddTableMigration(userV1))
}
